package mobidever.mygodutch.activity.base;

import java.lang.reflect.Field;

import mobidever.mygodutch.R;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.view.LayoutInflater;
import android.widget.Toast;

public class ActivityBase extends Activity
{
	protected void showMsg(String pMsg)
	{
		Toast.makeText(this, pMsg, Toast.LENGTH_LONG).show();
	}
	
	protected void openActivity(Class<?> pClass)
	{
		Intent _Intent = new Intent();
		_Intent.setClass(this, pClass);
		startActivity(_Intent);
	}
	
	protected LayoutInflater getMyLayoutInflater()
	{
		return LayoutInflater.from(this);
	}
	
	
	protected void setAlertDialogIsClose(DialogInterface pDialog,boolean pIsClose)
	{
		try 
		{
			Field _Field = pDialog.getClass().getSuperclass().getDeclaredField("mShowing");
			_Field.setAccessible(true);
			_Field.set(pDialog, pIsClose);
		} catch (Exception e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	
	protected boolean AlertDailogDeleteOrCanle(String pTitle, DialogInterface.OnClickListener _Listener)
	{
		AlertDialog.Builder _Builder = new AlertDialog.Builder(this);
		_Builder.setTitle(getString(R.string.DialogTitleDelete))
				.setMessage(pTitle)
				.setPositiveButton(getString(R.string.ButtonTextYes), _Listener)
				.setNegativeButton(getString(R.string.ButtonTextNo), null)
				.show();
		return false;
		
	}
}
